package com.terranovita.gaming.pulpgui.testscene;

import static pulpcore.image.Colors.rgb;
import pulpcore.Stage;
import pulpcore.scene.Scene2D;
import pulpcore.sprite.FilledSprite;

import com.terranovita.gaming.pulpgui.factories.ButtonFactory;
import com.terranovita.gaming.pulpgui.factories.LayoutFactory;
import com.terranovita.gaming.pulpgui.layout.FrameLayout;
import com.terranovita.gaming.pulpgui.layout.LinearLayout;
import com.terranovita.gaming.pulpgui.layout.StackLayout;

public class TestScene extends Scene2D
{
	@Override
	public void load()
	{
		// Add the background (sky-blue).
		FilledSprite background = new FilledSprite(rgb(185, 209, 255));
		add(background);
		
		// add a frame layout stretched over the entire stage and print elements in it's center.
		FrameLayout frame = new FrameLayout(Stage.getWidth(), Stage.getHeight());
		frame.setGravity(0.5, 0.5);
		add(frame);
		
		// A stack layout prints all elements added to it on top of eachother with their center in the center of the biggest sprite
		// In this case it is kinda pointless to use this layout because there is only one element added to it.
		StackLayout stack = new StackLayout();
		frame.add(stack);
		
		// A linear layout adds all children next to each other in an ordered fashing
		LinearLayout verticalLayout = LayoutFactory.createVerticalLayout(1.0, 0.5, 50, 5);
		stack.add(verticalLayout);
		// add first element to the layout
		verticalLayout.add(ButtonFactory.createLabeledButton("First button"));
		
		// adds a child LinearLayout with some horizontally aligned elements
		LinearLayout horizontalLayout = LayoutFactory.createHorizontalLayout(0.5, 0.5, 0, 5);
		verticalLayout.add(horizontalLayout);
		// add 2 elements to horizontal layout
		horizontalLayout.add(ButtonFactory.createCheckBox());
		horizontalLayout.add(ButtonFactory.createLabeledButton("Horizontal button"));
		
		// add the rest of the elements to the vertical layout
		verticalLayout.add(ButtonFactory.createLabeledButton("Third button"));
		verticalLayout.add(ButtonFactory.createLabeledButton("Fourth button"));
	}
}
